<% content_for :page_title do %>
  <span><%= stack.repo_owner %></span>
  <h1><%= stack.repo_name %> <%= stack.environment %></h1>
<% end %>


<% content_for :primary_navigation do %>
  <%= link_to t('stack.nav.refresh'), stack_refresh_path(stack), method: 'post', class: "header__btn btn" %>
<% end %>

<% content_for :secondary_navigation do %>
  <ul class="nav__list nav__list--primary">
    <li class="nav__list__item">
      <%= link_to t('stack.nav.commits'), stack_path(stack) %>
    </li>
    <li class="nav__list__item">
      <%= link_to t('stack.nav.settings'), stack_settings_path(stack) %>
    </li>
    <li class="nav__list__item">
      <%= link_to t('stack.nav.timeline'), index_stack_tasks_path(stack) %>
    </li>
    <li class="nav__list__item">
      <%= link_to t('stack.nav.statistics'), stack_statistics_path(stack) %>
    </li>
    <li class="nav__list__item">
      <%= link_to 'Repository', repository_path(stack.repository) %>
    </li>
    <% if stack.merge_queue_enabled? %>
      <li class="nav__list__item">
        <%= link_to t('stack.nav.merge_queue', count: stack.merge_requests.queued.count), stack_merge_requests_path(stack) %>
      </li>
    <% end %>

    <% if stack.task_definitions.present? %>
      <li class="nav__list__item nav__list__item--has-children">
        Tasks

        <ul class="nav__sub__list">
          <% stack.task_definitions.each do |definition| %>
            <li class="nav__list__sub__item">
              <%= link_to "#{definition.action}…", new_stack_tasks_path(stack, definition_id: definition.id), class: "trigger-deploy" %>
            </li>
          <% end %>
          <li class="nav__list__sub__item">
            <%= link_to "All tasks", stack_tasks_list_path(stack), class: "trigger-deploy" %>
          </li>
        </ul>
      </li>
    <% end %>

    <%= render partial: 'shipit/stacks/links', locals: { stack: stack } %>
  </ul>

  <ul class="nav__list nav__list--secondary">
    <% if stack.links.present? %>
      <li class="nav__list__item nav__list__item--has-children">

        <%=  t('stack.nav.links') %>

        <ul class="nav__sub__list">
          <% stack.links.each do |name, url| %>
            <li class="nav__list__sub__item">
              <%= link_to name.humanize, url, :target => '_blank', :class => "#{name.dasherize}-url" %>
            </li>
          <% end %>
        </ul>
      </li>
    <% end %>
    <li class="nav__list__item">
      <%= link_to t('stack.nav.view_on_github'), stack_github_url(stack) %>
    </li>
    <% if stack.deploy_url.present? %>
      <li class="nav__list__item">
        <%= sanitize link_to t('stack.nav.deploy_link'), stack.deploy_url, :target => '_blank', :class => 'deploy-url' %>
      </li>
    <% end %>
  </ul>
<% end %>
